package com.societyGames.flashForms
{
import flash.display.DisplayObject;

//Tries to take the whole width with each tile being equally wide.
public class HorizontalSquareTileContainer extends HorizontalTileContainer
{
  override protected function calculateWidth():void
  {
    var tileWidth:Number = Math.min(this._desiredHeight, this._desiredWidth / this._items.length);
    var tileX:Number = (this._desiredWidth - (tileWidth * this._items.length)) / 2;
    for each (var item:DisplayObject in this._items)
    {
      item.width = tileWidth;
      item.x = tileX;
      tileX += tileWidth;
      item.y = 0;
    }
  }

  override public function set height(value:Number):void
  {
    if (value != this._desiredHeight)
    {
      this._desiredHeight = value;
      calculateHeight();
      calculateWidth();
    }
  }
}
}